package request

import "egin/pkg/vali"

type MemberQs struct {
	Username        string `json:"username" form:"username" binding:"required,unique=member username" label:"用户名" unique-msg:"用户名已存在"`
	Name            string `json:"name" form:"name" binding:"required" label:"姓名" `
	Phone           string `json:"phone" form:"phone" binding:"required,regex,unique=member mobile" label:"手机号"  regex-msg:"请输入正确的手机号" unique-msg:"手机号已经存在"`
	Email           string `json:"email" form:"email" binding:"required,email,unique=member email" label:"邮箱" unique-msg:"邮箱已经存在"`
	Password        string `json:"password" form:"password" binding:"required" label:"密码"`
	ConfirmPassword string `json:"confirm_password" form:"confirm_password" binding:"required" label:"确认密码"`
	Role            string `json:"role" form:"role" `
	Sex             int8   `json:"sex" form:"sex" binding:"required" label:"性别"`
	Status          int8   `json:"status" form:"status"`
}

type MemberEditQs struct {
	Id       uint   `json:"id" form:"id" binding:"required"`
	Username string `json:"username" form:"username" binding:"required,unique=member username Id" label:"用户名" unique-msg:"用户名已存在"`
	Name     string `json:"name" form:"name" binding:"required" label:"姓名" `
	Phone    string `json:"phone" form:"phone" binding:"required,unique=member mobile Id,regex" label:"手机号"  regex-msg:"请输入正确的手机号" unique-msg:"手机号已经存在"`
	Email    string `json:"email" form:"email" binding:"required,email,unique=member email Id" label:"邮箱" unique-msg:"邮箱已经存在"`
	Role     string `json:"role" form:"role" `
	Sex      int8   `json:"sex" form:"sex" binding:"required" label:"性别"`
	Status   int8   `json:"status" form:"status"`
}

type MemberPwd struct {
	Id              uint   `json:"id" form:"id" binding:"required"`
	OldPassword     string `json:"old_password" form:"old_password" binding:"required" label:"旧密码"`
	Password        string `json:"password" form:"password" binding:"required" label:"新密码"`
	ConfirmPassword string `json:"confirm_password" form:"confirm_password" binding:"required,eqfield=Password" label:"确认密码" eqfield-msg:"确认密码与新密码不一致"`
}

func (c *MemberQs) CheckPhone() {
	vali.Regex("regex", `(13|14|15|16|17|18|19)[0-9]\d{8}`)
}

func (c *MemberEditQs) CheckPhone() {
	vali.Regex("regex", `(13|14|15|16|17|18|19)[0-9]\d{8}`)
}
